package egs;
/*public class varargs {
	varargs(String ... ppl){
		  for(String name:ppl){
			  System.out.println("Hello "+name);
		  }
	}
   	
	
	public static void main(String[] args) {
		varargs.varargs("","kjvhdjhv");	
	}
	
	}
	
	*/

public class varargs{
	public static double add(double... num){
		double sum=0;
		  for(int i=0;i<num.length;i++){
			  sum+=num[i];
		  }
		  return sum;
	}
	public static void main(String[] args){
		int isum=(int)varargs.add(1,2,3,4);
		float fsum=(float)varargs.add(0.5f,0.5f,0.5f,0.5f);
		double dsum=varargs.add(1,0.5f,0.5,5,4,6,10.0f);// all types
		System.out.println(isum);
	 System.out.println(fsum);
        System.out.println(dsum);	
 	}
}

		
	


